/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 86186
 * Date: 2023-08-19
 * Time: 16:55
 */
public class ThreadDemo3 {
    public static void main(String[] args) {
        Thread[] t = new Thread[20];
        for(int i = 0; i < 20; i++) {
            final int n = i;
            t[i] = new Thread(() -> {
                System.out.println(n);
            });
        }
        for(Thread thread : t) {
            thread.start();
        }

        for(Thread T : t) {
            try {
                T.join();
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
        }

        System.out.println("OK");

    }
}
